package com.unitech.drinks.vo;

import com.github.pagehelper.PageInfo;
import com.unitech.drinks.model.Drink;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 饮品分页返回对象
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ResponsePageDrinks {
    private long total;
    private long totalPages;
    private int  code;
    private List<ResponseDrink> drinks;

    public static ResponsePageDrinks converter(PageInfo<ResponseDrink> drinkPageInfo) {
        drinkPageInfo.getTotal();
        return ResponsePageDrinks
                .builder()
                .total(drinkPageInfo.getTotal())
                .totalPages(drinkPageInfo.getPages())
                .drinks(drinkPageInfo.getList())
                .build();
    }
}
